#!/bin/bash
#===============================================================================
# Copyright 2011 zod.yslin
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# 
# Author: zod.yslin
# Email: 
# File Name: demo.sh
# Description: 
#   If a word begins with an unquoted tilde character (‘~’), all of the 
#   characters up to the first unquoted slash (or all characters, 
#   if there is no unquoted slash) are considered a tilde-prefix.
#
#   If the tilde-prefix is ‘~+’, the value of the shell variable PWD replaces 
#   the tilde-prefix. If the tilde-prefix is ‘~-’, the value of the shell 
#   variable OLDPWD, if it is set, is substituted.
# Edit History: 
#   2011-10-04    File created.
#===============================================================================
h=~
echo $h
#The value of $HOME 
echo ~
#The value of $HOME 
echo ~/foo
#$HOME/foo 
echo ~zod/foo
#The subdirectory foo of the home directory of the user fred 
echo ~+/foo
#$PWD/foo 
echo ~-/foo
#${OLDPWD-'~-'}/foo 
pushd ~
pushd /etc
echo ~1
#The string that would be displayed by ‘dirs +N’ 
echo ~+1
#The string that would be displayed by ‘dirs +N’ 
echo ~-2
#The string that would be displayed by ‘dirs -N’
